const { Service } = require("egg");
const BusinessError = require('../utils/businessError')

class UserService extends Service {
  async login ({ username, password }) {
    let result = await this.app.mysql.get('base_account', { username })
    if (result) {
      if (result.password == password) {
        return result
      } else {
        throw new BusinessError('密码错误', 401)
      }
    } else {
      throw new BusinessError('该账号不存在', 401)
    }
  }
}

module.exports = UserService